package com.nulldev.util.concurrency.threadIt.v4.asyncTasks;

public interface AsyncTaskCallback<T> {

	/**
	 * Called on the successful completion of a task. <br>
	 * Also is called if the task is already completed. <br>
	 */
	public void onCompletion(final T result);

	/**
	 * Called on the failure of a task. <br>
	 */
	public default void onError(final Throwable e) {
		throw new RuntimeException(e);
	}

	/**
	 * Currently optionally supported by executors.
	 */
	public default void onQueued() {
	}

	/**
	 * Currently optionally supported by executors.
	 */
	public default void onSubmissionRejection() {
	}

// 	REMOVED AS OF FURTHER NOTICE.
//	/**
//	 * Called on the pre-execution (start) of a task. <br>
//	 * <b style="color: orange;">WARNING: This runs on the main thread of the Task, this will delay the thread and other queued callbacks!</b>
//	 */
//	public void onStart();
}
